﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;

namespace AmiEmuLib.Configuration.FiltersConfig
{
    /// <summary>
    /// List of all available filters.
    /// </summary>
    public static class Filters
    {
        /// <summary>
        /// List of filters.
        /// </summary>
        private static List<Filter> m_list = new List<Filter>();

        /// <summary>
        /// Static constructor.
        /// </summary>
        static Filters()
        {
            foreach (var f in Render.Filter.ShaderFilter.Shaders.GetShadersNames())
                m_list.Add(new Filter(f, FilterType.Shader));
                    
            foreach (var f in Render.Filter.SoftwareFilter.SoftwareFilters.Filters)
                m_list.Add(new Filter(f.Name, FilterType.Software));
        }

        /// <summary>
        /// Get filter with specified display name. Display names are unique.
        /// </summary>
        /// <param name="a_display_name"></param>
        /// <returns></returns>
        public static Filter GetFilterByDisplayName(string a_display_name)
        {
            return m_list.FirstOrDefault(f => f.DisplayName == a_display_name);
        }

        /// <summary>
        /// Ge filter with specified name and type. Names are not unique.
        /// </summary>
        /// <param name="a_name"></param>
        /// <param name="a_type"></param>
        /// <returns></returns>
        public static Filter GetFilterByName(string a_name, FilterType a_type)
        {
            return m_list.FirstOrDefault(f => (f.Name == a_name) && (f.Type == a_type));
        }

        /// <summary>
        /// List of filters.
        /// </summary>
        /// <returns></returns>
        public static IEnumerable<Filter> List
        {
            get
            {
                return m_list;
            }
        }
    }
}
